package com.frogs.ucenter.v1.request;

import java.util.Date;

import javax.servlet.http.HttpServletRequest;

import com.frogs.framework.util.StringUtil;
import com.frogs.framework.web.HttpRequestInfo;
import com.frogs.system.util.ApiUrlParamEnum;
import com.frogs.system.util.SexEnum;
import com.frogs.system.web.api.request.Request;
import com.frogs.system.web.exception.RequestIllegalException;

public class UserFamilyMemberAddRequest extends Request {

	private static final long serialVersionUID = 5473490731166489412L;

	private String relatives;

    private int rank = 0;

    private int sex;
    
    private int age;
    
    private int weight;
    
    private int height;

	private int ageLowerLimit = 0;

    private int ageUpperLimit = 0;

    private String diseaseTag;

    private String medicationContraindicationsTag;

    private String healthConditionTag;

    private String otherTag;

    private String name;

    private int identityType = 0;

    private String identityCard;

    private String healthInsuranceInfo;
	
	private int userId ;
	
	private Date birthday;
	
	public Date getBirthday() {
		return birthday;
	}

	public void setBirthday(Date birthday) {
		this.birthday = birthday;
	}

	private String phone;

	private String ip;
	
	/** */
	public UserFamilyMemberAddRequest() {
	}

	@Override
	public void parse(HttpServletRequest request) {
		
		HttpRequestInfo requestInfo = new HttpRequestInfo(request);
		
		
		this.userId = requestInfo.getIntParameter(ApiUrlParamEnum.userId.getParamName(), -1);
		if( userId < 1) {
			throw new RequestIllegalException("error userId:"+userId);
		}
		
		this.age = requestInfo.getIntParameter(ApiUrlParamEnum.age.getParamName(), -1);
		if(age < 0) {
			throw new RequestIllegalException("error age:"+age);
		}

		this.relatives = requestInfo.getParameter(ApiUrlParamEnum.relatives.getParamName(),"-");
		this.rank = requestInfo.getIntParameter(ApiUrlParamEnum.rank.getParamName() , 0);
		this.sex = requestInfo.getIntParameter(ApiUrlParamEnum.sex.getParamName(),SexEnum.UNKNOW.getId());
		this.ageLowerLimit = requestInfo.getIntParameter(ApiUrlParamEnum.ageLowerLimit.getParamName());
		this.ageUpperLimit = requestInfo.getIntParameter(ApiUrlParamEnum.ageUpperLimit.getParamName());
		this.diseaseTag = requestInfo.getParameter(ApiUrlParamEnum.diseaseTag.getParamName());
		this.medicationContraindicationsTag = requestInfo.getParameter(ApiUrlParamEnum.medicationContraindicationsTag.getParamName());
		this.healthConditionTag = requestInfo.getParameter(ApiUrlParamEnum.healthConditionTag.getParamName());
		this.otherTag = requestInfo.getParameter(ApiUrlParamEnum.otherTag.getParamName());
		this.name = StringUtil.fixHtml(requestInfo.getParameter(ApiUrlParamEnum.name.getParamName()));
		this.identityType = requestInfo.getIntParameter(ApiUrlParamEnum.identityType.getParamName());
		this.identityCard = requestInfo.getParameter(ApiUrlParamEnum.identityCard.getParamName());
		this.healthInsuranceInfo = requestInfo.getParameter(ApiUrlParamEnum.healthInsuranceInfo.getParamName());
		this.weight = requestInfo.getIntParameter(ApiUrlParamEnum.weight.getParamName(), 0);
		this.height = requestInfo.getIntParameter(ApiUrlParamEnum.height.getParamName(), 0);
		this.birthday = requestInfo.getDateParameter(ApiUrlParamEnum.birthday.getParamName(), "yyyy-MM-dd");
		this.phone = requestInfo.getParameter(ApiUrlParamEnum.phone.getParamName(), "");
		
		this.ip = requestInfo.getParameter(ApiUrlParamEnum.ip.getParamName(), requestInfo.getUserIp());
	}
	
	public int getUserId() {
		return userId;
	}
	
	public void setUserId(int userId) {
		this.userId = userId;
	}

	public String getRelatives() {
		return relatives;
	}

	public void setRelatives(String relatives) {
		this.relatives = relatives;
	}

	public int getRank() {
		return rank;
	}

	public void setRank(int rank) {
		this.rank = rank;
	}

	public int getSex() {
		return sex;
	}

	public void setSex(int sex) {
		this.sex = sex;
	}

	public int getAgeLowerLimit() {
		return ageLowerLimit;
	}

	public void setAgeLowerLimit(int ageLowerLimit) {
		this.ageLowerLimit = ageLowerLimit;
	}

	public int getAgeUpperLimit() {
		return ageUpperLimit;
	}

	public void setAgeUpperLimit(int ageUpperLimit) {
		this.ageUpperLimit = ageUpperLimit;
	}

	public String getDiseaseTag() {
		return diseaseTag;
	}

	public void setDiseaseTag(String diseaseTag) {
		this.diseaseTag = diseaseTag;
	}

	public String getMedicationContraindicationsTag() {
		return medicationContraindicationsTag;
	}

	public void setMedicationContraindicationsTag(
			String medicationContraindicationsTag) {
		this.medicationContraindicationsTag = medicationContraindicationsTag;
	}

	public String getHealthConditionTag() {
		return healthConditionTag;
	}

	public void setHealthConditionTag(String healthConditionTag) {
		this.healthConditionTag = healthConditionTag;
	}

	public String getOtherTag() {
		return otherTag;
	}

	public void setOtherTag(String otherTag) {
		this.otherTag = otherTag;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getIdentityType() {
		return identityType;
	}

	public void setIdentityType(int identityType) {
		this.identityType = identityType;
	}

	public String getIdentityCard() {
		return identityCard;
	}

	public void setIdentityCard(String identityCard) {
		this.identityCard = identityCard;
	}

	public String getHealthInsuranceInfo() {
		return healthInsuranceInfo;
	}

	public void setHealthInsuranceInfo(String healthInsuranceInfo) {
		this.healthInsuranceInfo = healthInsuranceInfo;
	}
	
	public int getAge() {
		return this.age;
	}
	
	public void setAge(int age) {
		this.age = age;
	}
	
	public int getWeight() {
		return weight;
	}

	public void setWeight(int weight) {
		this.weight = weight;
	}

	public int getHeight() {
		return height;
	}

	public void setHeight(int height) {
		this.height = height;
	}
	
	public String getPhone() {
		return this.phone;
	}
	
	public void setPhone( String phone) {
		this.phone = phone;
	}
	
	public String getIp() {
		return ip;
	}
	
	public void setIp(String ip) {
		this.ip = ip;
	}
}
